﻿using System.Collections.Generic;
using System.Text;
using System.Linq;
using System;
using System.ServiceModel;
using System.Threading.Tasks;

namespace Elderos.Highlight.Services
{
    public class WebHighlighterService : IHighlighterService
    {
        private ChannelFactory<IHighlighter> _factory;

        public WebHighlighterService(string endpointName)
        {
            _factory = new ChannelFactory<IHighlighter>(endpointName);
        }

        #region Implementation of IHighlighterService

        public async Task<HighlightResult> HighlightText(HighlightArgs args)
        {
            var client = _factory.CreateChannel();
            return await Task.Run(() => client.Highlight(args.Text));
        }

        #endregion
    }
}